#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QSerialPort>
#include <QPushButton>
#include <QTimer>
#include <QFile>
#include <QDateTime>
#include <QLineEdit>
#include <QCheckBox>
#include <QList>
//#include "mythread.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
//    static int getTime(){return getCircleTime;};
    QString getDateTime();
    void circleSentRule(bool flag);
    void  uiMemInit();
    void serialDevlInit();

protected:
     bool eventFilter(QObject *obj, QEvent *ev) override;

private slots:
    void on_pushButton_openorclosecom_clicked();
    void on_pushButton_sent_clicked();
    void SerialRecvCallback();
    void on_checkBox_timesent_clicked(bool checked);
    void on_pushButton_clearrec_clicked();
    void on_pushButton_saverec_clicked();
    void timeRefreshPerSecFunc();
    void on_checkBox_hexdisplay_clicked(bool checked);
    void on_pushButton_hidetemplate_clicked(bool checked);
    void on_pushButton_hidehistory_clicked(bool checked);
    void on_pushButton_clicked(int num);
    void on_checkBox_circlesent_clicked(bool checked);
    void circleSendCallBack();
    void on_pushButton_save_clicked();
    void on_pushButton_load_clicked();
    void on_pushButton_reset_clicked();

private:
    Ui::Widget *ui;
    QSerialPort  *serialPort;
    int sendCnt;
    int recvCnt;
    QString sendBak;
    QList<QPushButton*> buttonList;
    QList<QLineEdit*> textList;
    QList<QCheckBox*> checkBoxList;
    QTimer *timer;
    QTimer *timerRefresh;
    QTimer *timerCircle;
//    mythread *circleThread;
    QFile file;
    QDateTime currentTime;
//    static int getCircleTime;
};
#endif // WIDGET_H
